﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.CApFLEXAttachmentErrorMessage
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using DnProcessSimulateCommands.Flexibles;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands;

public class CApFLEXAttachmentErrorMessage
{
  public CApFLEXAttachmentErrorMessage()
  {
    this.DistanceFromAttachment1 = 0.0;
    this.DistanceFromAttachment2 = 0.0;
    this.AttachmentErrorType = CApFLEXAttachmentErrorMessage.EAttachmentErrorType.None;
    this.BoundType = CApFLEXAttachmentErrorMessage.EAttachmentBoundType.Minimum;
    this.Scope = CApFLEXAttachmentErrorMessage.EAttachmentMessageScope.Local;
    this.AttachmentType = CApFLEXAttachmentType.Fixed;
    this.AttachmentRank = 0;
  }

  public CApFLEXAttachmentType AttachmentType { private get; set; }

  public string AttachmentTypeString
  {
    get => CApFLEXAttachment.AttachmentTypeToString(this.AttachmentType);
  }

  public int AttachmentRank { get; set; }

  public double LowerBound { get; set; }

  public double UpperBound { get; set; }

  public double DistanceFromAttachment1 { get; set; }

  public double DistanceFromAttachment2 { get; set; }

  public CApFLEXAttachmentErrorMessage.EAttachmentErrorType AttachmentErrorType { get; set; }

  public CApFLEXAttachmentErrorMessage.EAttachmentMessageScope Scope { get; set; }

  public CApFLEXAttachmentErrorMessage.EAttachmentBoundType BoundType { get; set; }

  public string AttachFrame1 { get; set; }

  public string AttachFrame2 { get; set; }

  public string GetErrorMessage()
  {
    string errorMessage = "";
    switch (this.AttachmentErrorType)
    {
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.StartAttachmentPercentageLengthError:
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.AttachmentAttachmentPercentageLengthError:
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.AttachmentEndPercentageLengthError:
        errorMessage = this.GetPercentageAttachmentErrorMessage();
        break;
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.AttachmentDistanceError:
        errorMessage = this.GetDistanceAttachmentErrorMessage();
        break;
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.AttachmentSecondaryDistanceError:
        errorMessage = this.GetSecondaryDistanceAttachmentErrorMessage();
        break;
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.AttachmentPrimaryAndSecondaryDistanceError:
        errorMessage = this.GetDistancePrimaryAndSecondaryFrameErrorMessage();
        break;
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.AttachmentPrimaryDistanceInconsistencyError:
        errorMessage = this.GetDistancePrimaryFrameInconsistencyErrorMessage();
        break;
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.AttachmentDistanceInconsistencyWithRetractSystemError:
        errorMessage = this.GetDistanceInconsistencyWithRetractSystemErrorMessage();
        break;
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.ExistingFixedAttachmentAndRetractSystemError:
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.ExistingRetractSystemAndFixedAttachmentError:
        errorMessage = this.GetFixedAndRetractSystemAttachmentErrorMessage();
        break;
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.ExistingRotatingAttachmentAndRetractSystemError:
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.ExistingRetractSystemAndRotatingAttachmentError:
        errorMessage = this.GetRotatingAndRetractSystemAttachmentErrorMessage();
        break;
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.ExistingRotatingSlidingAttachmentAndRetractSystemError:
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.ExistingRetractSystemAndRotatingSlidingAttachmentError:
        errorMessage = this.GetRotatingSlidingAndRetractSystemAttachmentErrorMessage();
        break;
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.CanNotCreateAttachmentError:
        errorMessage = this.GetCreationFailedErrorMessage();
        break;
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.AttachmentEquipmentFrameIsNotPreserved:
        errorMessage = this.GetNonPreservedAttachmentFrame();
        break;
    }
    return errorMessage;
  }

  public string GetCreationFailedErrorMessage() => CApFLEXStringTable.CanNotCreateAttachment;

  public string GetPercentageAttachmentErrorMessage()
  {
    string str = (this.DistanceFromAttachment1 / TxApplication.Options.Units.LinearMultiplier).ToString(CApCableUtility.NumericLinearFormat);
    string linearUnitName = TxApplication.Options.Units.LinearUnitName;
    string attachmentErrorMessage = "";
    switch (this.AttachmentErrorType)
    {
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.StartAttachmentPercentageLengthError:
        attachmentErrorMessage = string.Format(CApFLEXStringTable.PercentageDistanceStartAttachmentErrorMessage, (object) str, (object) linearUnitName);
        break;
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.AttachmentAttachmentPercentageLengthError:
        attachmentErrorMessage = string.Format(CApFLEXStringTable.PercentageDistanceBetweenAttachmentErrorMessage, (object) str, (object) linearUnitName);
        break;
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.AttachmentEndPercentageLengthError:
        attachmentErrorMessage = string.Format(CApFLEXStringTable.PercentageDistanceEndAttachmentErrorMessage, (object) str, (object) linearUnitName);
        break;
    }
    return attachmentErrorMessage;
  }

  public string GetFixedAndRetractSystemAttachmentErrorMessage()
  {
    string str1 = (this.LowerBound / TxApplication.Options.Units.LinearMultiplier).ToString(CApCableUtility.NumericLinearFormat);
    string str2 = (this.UpperBound / TxApplication.Options.Units.LinearMultiplier).ToString(CApCableUtility.NumericLinearFormat);
    string linearUnitName = TxApplication.Options.Units.LinearUnitName;
    string attachmentErrorMessage = "";
    switch (this.AttachmentErrorType)
    {
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.ExistingFixedAttachmentAndRetractSystemError:
        attachmentErrorMessage = string.Format(CApFLEXStringTable.FixedAttachmentPreventRetractSystemCreationErrorMessage);
        break;
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.ExistingRetractSystemAndFixedAttachmentError:
        attachmentErrorMessage = string.Format(CApFLEXStringTable.FixedAttachmentIsInRetractSectionOfRetractSystemErrorMessage, (object) str1, (object) str2, (object) linearUnitName);
        break;
    }
    return attachmentErrorMessage;
  }

  public string GetRotatingAndRetractSystemAttachmentErrorMessage()
  {
    string str1 = (this.LowerBound / TxApplication.Options.Units.LinearMultiplier).ToString(CApCableUtility.NumericLinearFormat);
    string str2 = (this.UpperBound / TxApplication.Options.Units.LinearMultiplier).ToString(CApCableUtility.NumericLinearFormat);
    string linearUnitName = TxApplication.Options.Units.LinearUnitName;
    string attachmentErrorMessage = "";
    switch (this.AttachmentErrorType)
    {
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.ExistingRotatingAttachmentAndRetractSystemError:
        attachmentErrorMessage = string.Format(CApFLEXStringTable.RotatingAttachmentPreventRetractSystemCreationErrorMessage);
        break;
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.ExistingRetractSystemAndRotatingAttachmentError:
        attachmentErrorMessage = string.Format(CApFLEXStringTable.RotatingAttachmentIsInRetractSectionOfRetractSystemErrorMessage, (object) str1, (object) str2, (object) linearUnitName);
        break;
    }
    return attachmentErrorMessage;
  }

  public string GetRotatingSlidingAndRetractSystemAttachmentErrorMessage()
  {
    string str1 = (this.LowerBound / TxApplication.Options.Units.LinearMultiplier).ToString(CApCableUtility.NumericLinearFormat);
    string str2 = (this.UpperBound / TxApplication.Options.Units.LinearMultiplier).ToString(CApCableUtility.NumericLinearFormat);
    string linearUnitName = TxApplication.Options.Units.LinearUnitName;
    string attachmentErrorMessage = "";
    switch (this.AttachmentErrorType)
    {
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.ExistingRotatingSlidingAttachmentAndRetractSystemError:
        attachmentErrorMessage = string.Format(CApFLEXStringTable.RotatingSlidingAttachmentPreventRetractSystemCreationErrorMessage);
        break;
      case CApFLEXAttachmentErrorMessage.EAttachmentErrorType.ExistingRetractSystemAndRotatingSlidingAttachmentError:
        attachmentErrorMessage = string.Format(CApFLEXStringTable.RotatingSlidingAttachmentIsInRetractSectionOfRetractSystemErrorMessage, (object) str1, (object) str2, (object) linearUnitName);
        break;
    }
    return attachmentErrorMessage;
  }

  public string GetDistanceAttachmentErrorMessage()
  {
    string str1 = (this.DistanceFromAttachment1 / TxApplication.Options.Units.LinearMultiplier).ToString(CApCableUtility.NumericLinearFormat);
    string linearUnitName = TxApplication.Options.Units.LinearUnitName;
    string attachmentErrorMessage = "";
    string str2 = this.ConvertBoundTypeToString(this.BoundType);
    if (this.Scope == CApFLEXAttachmentErrorMessage.EAttachmentMessageScope.Local)
    {
      if (this.BoundType == CApFLEXAttachmentErrorMessage.EAttachmentBoundType.Minimum)
        attachmentErrorMessage = string.Format(CApFLEXStringTable.MinDistanceAttachmentErrorMessage, (object) str2, (object) str1, (object) linearUnitName, (object) this.AttachFrame1);
      else if (this.BoundType == CApFLEXAttachmentErrorMessage.EAttachmentBoundType.Maximum)
        attachmentErrorMessage = string.Format(CApFLEXStringTable.MaxDistanceAttachmentErrorMessage, (object) str2, (object) str1, (object) linearUnitName, (object) this.AttachFrame1);
    }
    else
      attachmentErrorMessage = string.Format(CApFLEXStringTable.GlobalDistanceAttachmentErrorMessage, (object) str2, (object) (this.AttachmentRank + 1), (object) this.AttachmentTypeString, (object) str1, (object) linearUnitName, (object) this.AttachFrame1, (object) this.AttachFrame2);
    return attachmentErrorMessage;
  }

  public string GetSecondaryDistanceAttachmentErrorMessage()
  {
    string str1 = (this.DistanceFromAttachment1 / TxApplication.Options.Units.LinearMultiplier).ToString(CApCableUtility.NumericLinearFormat);
    string linearUnitName = TxApplication.Options.Units.LinearUnitName;
    string attachmentErrorMessage = "";
    string str2 = this.ConvertBoundTypeToString(this.BoundType);
    if (this.Scope == CApFLEXAttachmentErrorMessage.EAttachmentMessageScope.Local)
    {
      if (this.BoundType == CApFLEXAttachmentErrorMessage.EAttachmentBoundType.Minimum)
        attachmentErrorMessage = string.Format(CApFLEXStringTable.MinSecondaryDistanceAttachmentErrorMessage, (object) str2, (object) str1, (object) linearUnitName, (object) this.AttachFrame1);
      else if (this.BoundType == CApFLEXAttachmentErrorMessage.EAttachmentBoundType.Maximum)
        attachmentErrorMessage = string.Format(CApFLEXStringTable.MaxSecondaryDistanceAttachmentErrorMessage, (object) str2, (object) str1, (object) linearUnitName, (object) this.AttachFrame1);
    }
    else
      attachmentErrorMessage = string.Format(CApFLEXStringTable.GlobalSecondaryDistanceAttachmentErrorMessage, (object) str2, (object) (this.AttachmentRank + 1), (object) this.AttachmentTypeString, (object) str1, (object) linearUnitName, (object) this.AttachFrame1, (object) this.AttachFrame2);
    return attachmentErrorMessage;
  }

  public string GetDistancePrimaryAndSecondaryFrameErrorMessage()
  {
    return string.Format(CApFLEXStringTable.LengthBetweenPrimaryAndSecondaryAttachmentErrorMessage, (object) (this.DistanceFromAttachment1 / TxApplication.Options.Units.LinearMultiplier).ToString(CApCableUtility.NumericLinearFormat), (object) TxApplication.Options.Units.LinearUnitName, (object) this.AttachFrame1, (object) this.AttachFrame2);
  }

  public string GetDistancePrimaryFrameInconsistencyErrorMessage()
  {
    return string.Format(CApFLEXStringTable.AttachmentLengthIsInconsistentWithSecondaryLength, (object) (this.AttachmentRank + 1), (object) this.AttachmentTypeString, (object) (this.DistanceFromAttachment1 / TxApplication.Options.Units.LinearMultiplier).ToString(CApCableUtility.NumericLinearFormat), (object) TxApplication.Options.Units.LinearUnitName);
  }

  public string GetDistanceInconsistencyWithRetractSystemErrorMessage()
  {
    return string.Format(CApFLEXStringTable.AttachmentLengthIsInconsistentWithRetractSystem, (object) (this.AttachmentRank + 1), (object) this.AttachmentTypeString, (object) (this.DistanceFromAttachment1 / TxApplication.Options.Units.LinearMultiplier).ToString(CApCableUtility.NumericLinearFormat), (object) TxApplication.Options.Units.LinearUnitName);
  }

  public string GetNonPreservedAttachmentFrame()
  {
    return CApFLEXStringTable.AttachmentFrameIsNotPreserved;
  }

  public string ConvertBoundTypeToString(
    CApFLEXAttachmentErrorMessage.EAttachmentBoundType type)
  {
    string str;
    switch (this.BoundType)
    {
      case CApFLEXAttachmentErrorMessage.EAttachmentBoundType.Minimum:
        str = "Minimum";
        break;
      case CApFLEXAttachmentErrorMessage.EAttachmentBoundType.Maximum:
        str = "Maximum";
        break;
      default:
        str = "";
        break;
    }
    return str;
  }

  public enum EAttachmentErrorType
  {
    StartAttachmentPercentageLengthError,
    AttachmentAttachmentPercentageLengthError,
    AttachmentEndPercentageLengthError,
    AttachmentDistanceError,
    AttachmentSecondaryDistanceError,
    AttachmentPrimaryAndSecondaryDistanceError,
    AttachmentPrimaryDistanceInconsistencyError,
    AttachmentDistanceInconsistencyWithRetractSystemError,
    ExistingFixedAttachmentAndRetractSystemError,
    ExistingRetractSystemAndFixedAttachmentError,
    ExistingRotatingAttachmentAndRetractSystemError,
    ExistingRetractSystemAndRotatingAttachmentError,
    ExistingRotatingSlidingAttachmentAndRetractSystemError,
    ExistingRetractSystemAndRotatingSlidingAttachmentError,
    CanNotCreateAttachmentError,
    AttachmentEquipmentFrameIsNotPreserved,
    None,
  }

  public enum EAttachmentBoundType
  {
    Minimum,
    Maximum,
    MinMax,
  }

  public enum EAttachmentMessageScope
  {
    Local,
    Global,
  }
}
